import request from '@/utils/request.js'
import store from '@/store'
// 登陆
export function authorizations (data) {
  return request({
    url: '/v1_0/authorizations',
    method: 'post',
    // 不需加token
    noToken: true,
    noError: true,
    data
  })
}
// 验证码发送
export const smsCodes = mobile => {
  return request({
    url: `/v1_0/sms/codes/${mobile}`
  })
}
// 获取用户个人资料
export function userProfile () {
  return request({
    url: '/v1_0/user/profile'
  })
}
// 个人性别修改
export function userProfilePatch (data) {
  return request({
    url: '/v1_0/user/profile',
    method: 'patch',
    data
  })
}
// 编辑用户照片资料
export function userPhotoPatch (data) {
  return request({
    url: '/v1_0/user/photo',
    method: 'patch',
    data
  })
}
// 刷新用户token
export function authorizationsPut () {
  return request({
    url: '/v1_0/authorizations',
    method: 'put',
    noToken: true, // 不让请求拦截添加token
    headers: {
      Authorization: `Bearer ${store.state.user.refresh_token}`
    }
  })
}
